home *** CD-ROM | disk | FTP | other *** search
- Path: dawn.mmm.com!news
- From: kjhopps@mmm.com (Kevin J Hopps)
- Newsgroups: comp.lang.c++
- Subject: Re: C++ compilers
- Date: 2 Jan 1996 14:07:34 GMT
- Organization: 3M - St. Paul, MN 55144-1000 US
- Message-ID: <4cbe76$kst@dawn.mmm.com>
- References: <4bajl8$fsh@castle.nando.net> <kshadowe.123.00143C15@iamerica.net> <4bs061$hh3@nntpa.cb.att.com>
- Reply-To: kjhopps@mmm.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- -D.OBrien (dob@cbsky.cb.att.com) wrote:
- > In article <kshadowe.123.00143C15@iamerica.net>,
- > <kshadowe@iamerica.net> wrote:
- > >In article <4bajl8$fsh@castle.nando.net> nhawk <nhawk@mailhost.nando.net> writes:
- > >
- > >
- > >>Hello All,
- > >
- > >>I am a beginner learning to program in C++. I have Borland's Turbo C++
- > >>for DOS and Turbo C++ Visual edition, AT&T C++ 2.? and GNU C++ 2.7.0.
- > >>Only the latter, in my experience, supports Boolean types. What other C++
- > >>compilers currently support Boolean types? How about Watcom C++? Any help
- > >>will be appreciated.
- > >
- > > How about to write
- > >
- > > #define FALSE 0
- > > #define TRUE 1
- > > enum BOOLEAN {FALSE,TRUE};
-
- > How about just:
-
- > enum BOOLEAN {FALSE, TRUE};
-
- My approach would be to define things so as to minimize the impact when my
- compiler supported the new keywords. This means that my solution would
- have to use "bool" as the type name, and "true" and "false" as values
- for the type "bool."
-
- Now, depending on whether I want to distinguish between bool and other
- built in types (perhaps for overloading purposes) or whether I want
- automatic conversion between int and bool, I would use an enum or a
- typedef. I happen to not care about overloading, so I have taken this
- approach:
- #ifndef HAVE_BUILTIN_BOOL
- typedef int bool;
- const bool true = 1;
- const bool false = 0;
- #endif
-
- When my compiler supports the bool type, I will turn this code off.
- --
- Kevin J. Hopps e-mail: kjhopps@mmm.com
- 3M Company phone: (612) 737-4643
- 3M Center, Bldg. 235-2D-57 fax: (612) 737-2700
- St. Paul, MN 55144-1000 Opinions are my own. I don't speak for 3M.
- But 3M speaks for me -- I did not write the following line:
-
- Opinions expressed herein are my own and may not represent those of 3M.
-